import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'
// import TestView from '../views/TestView.vue'
import MainView from '../views/MainView.vue'
import StudentList from '../views/StudentListView.vue'
import TeacherList from '../views/TeacherListView.vue'
import StudentAdd from '../views/StudentAddView.vue'
import Login from '../views/LoginView.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect:'/login'

  },
  {
    path: '/login',
    name: 'login',
    component: Login
  },
  {
    path: '/',
    name: 'home',
    component: HomeView
  },
   {
    path: '/main',
    name: 'MainView',
    component: MainView,
    //子路由
    children:[
      {
        path: '/',
        redirect:'/studentlist'
      },
      {
        path: '/studentlist',
        name: 'StudentList',
        component: StudentList
      },
      {
        path: '/teacherlist',
        name: 'teacherList',
        component: TeacherList
      },{
        path: '/studentAdd',
        name: 'studentAdd',
        component: StudentAdd
      },
    ]
  },
  // {
  //   path: '/test',
  //   name: 'test',
  //   component: TestView
  // },
  {
    path: '/about',
    name: 'about',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  },
  
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
